<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

require_once 'frm/init.php';

/*************** MAIL *************************************
$mail = new Ftl_Mail( array(

	'from'		=> 'lucasgrzina@gmail.com',

	'to'		=> 'lucasgrzina@gmail.com',

	'cc'		=> array( 'to1@example.com', 'to2@example.com', 'to3@example.com'),
	
	'bcc'		=> 'lucas.grzina@webar.net',
	
	'subject'	=> 'Subject ¿¡áëíÖÚñÑ"!?',

	'body'		=> 'Email Content ¡ñóä!'

) );
$mail->send();
************************************************************/

/****************** ARRAY ***********************************

$aDatos = array(
    "nombre"    => "Lucas",
    "apellido"  => "Grzina",
    "amigos"    => array("Dami","Tavo"),
    "programa"  => array(
                            "dotNet" => array("C","VB"),
                            "android"=> "android"
    )
);

//var_dump($aDatos);

$oDatos = Ftl_ArrayUtil::toObject($aDatos);

echo $oDatos->amigos->{0};
/******************************************************************************/


/****************OBJECT**********************************************************/
$z = new stdClass();
$z->test = 10;

$o = new stdClass();
$o->firstname = array(
	'object'	=> $z
);
$o->lastname = 'Lastname';
$o->children = new stdClass();
$o->children->children = 1;
$o->child = new stdClass();
$o->child->child = new stdClass();
$o->child->child->child = 1;


var_dump (Ftl_ObjectUtil::toArray($o));

/**************************************************************************/

//

//require_once 'frm/DB/MySql/MySql.php';
/*
echo "Entorno: "        . ENTORNO_ACTUAL . '<br>';
echo "WEB_ROOT: "       . WEB_ROOT . '<br>';
echo "WEB_ROOT_URL: "   . WEB_ROOT_URL . '<br>';

$oDb = MySql::getInstance(DB_HOST,DB_USER,DB_PASS,DB_BASE);

$aDatos = array(
    "nombre"  => "lucas",
    "fecha" => "NOW()",
    "apellido" => null
);
echo $oDb->insert("usuarios",$aDatos,true);

var_dump($oDb->fetchById('usuarios',2,2));

$aDatos['nombre'] = 'Edu';

$aWhere = array(
    "id"    => 2
);


$oDb->update("usuarios",$aWhere,$aDatos);


$oDb = MySql::getInstance(DB_HOST,DB_USER,DB_PASS,DB_BASE);

$aDatos = array(
    "nombre"  => (isset($_REQUEST['t'])?$_REQUEST['t']:''),
    "fecha" => "NOW()",
    "apellido" => (isset($_REQUEST['t'])?$_REQUEST['t']:'')
);

$id = $oDb->insert("usuarios",$aDatos,true);
$res = $oDb->fetchById('usuarios',$id,2);

echo "<form name='frm' method='post' action='test.php'><br>";
echo "<textarea name='t' rows=10 cols=20>" . ($res ? $res->{0}->nombre : "") . "</textarea><br>";
echo "<input type=submit /><br>";
echo "</form><br>";

echo "<textarea name='t2' rows=10 cols=20>". $res->{0}->nombre  . "</textarea><br>";

echo "SI: " . $res->{0}->nombre . "<br>";
echo "SI/NO: " . $oDb->unscape($res->{0}->nombre) . "<br>";
echo "NO: " . $res->{0}->apellido . "<br>";
*/


//$hola = Ftl_MySql::getInstance(DB_HOST,DB_USER,DB_PASS,DB_BASE);
/*
Ftl_Header::setCharsetEncoding();
$json = Ftl_JsonUtil::encode(array("estado" => 1, "nombre" => "Lícas"));
echo "Lícas";
var_dump (Ftl_JsonUtil::decode($json));
*/

?>
